Skip to content

Conversation

@brfrn169
Copy link
Collaborator

@brfrn169 brfrn169 commented May 26, 2025

Description

This PR adds the getScanner() method to the transaction interfaces. It does not include the actual implementations; those will be provided in subsequent PRs.

Note that we are working on this feature in the add-scanner-api-to-transaction-abstraction feature branch, as this change may cause compile errors in dependent projects. Once all implementations are completed, we will merge the feature branch into the master branch.

Related issues and/or PRs

N/A

Changes made

  • Added the getScanner() method and the Scanner interface to CrudOperable.
  • Added the getScanner() method and the Scanner interface to TransactionManagerCrudOperable.
  • Added the getScanner() method and the Scanner interface to TransactionCrudOperable.
  • Added integration tests for the getScanner() method.

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

N/A

@brfrn169 brfrn169 requested a review from Copilot May 26, 2025 14:03
@brfrn169 brfrn169 self-assigned this May 26, 2025
@brfrn169 brfrn169 requested a review from a team as a code owner May 26, 2025 14:03
@brfrn169 brfrn169 requested review from Torch3333, feeblefakie and komamitsu and removed request for a team May 26, 2025 14:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new getScanner(Scan) method to the transaction CRUD interfaces, provides a base scanner implementation, and wires up stub or delegated implementations throughout the core and service layers.

  • Extended CrudOperable, TransactionCrudOperable, and TransactionManagerCrudOperable with getScanner(Scan) and a nested Scanner interface.
  • Added AbstractCrudOperableScanner (and two specialized subclasses) to provide a reusable iterator-based scanner implementation.
  • Implemented stub or delegated getScanner overrides across transaction, manager, and service classes; added placeholder integration tests.

Reviewed Changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
core/src/main/java/com/scalar/db/transaction/consensuscommit/TwoPhaseConsensusCommit.java Added stub getScanner method
core/src/main/java/com/scalar/db/transaction/consensuscommit/ConsensusCommitManager.java Added stub getScanner method
core/src/main/java/com/scalar/db/transaction/consensuscommit/ConsensusCommit.java Added stub getScanner method
core/src/main/java/com/scalar/db/service/TwoPhaseCommitTransactionService.java Delegated getScanner to manager; updated deprecations
core/src/main/java/com/scalar/db/service/TransactionService.java Delegated getScanner to manager; updated deprecations
core/src/main/java/com/scalar/db/common/StateManagedTwoPhaseCommitTransactionManager.java Added active-check + delegate getScanner
core/src/main/java/com/scalar/db/common/StateManagedDistributedTransactionManager.java Added active-check + delegate getScanner
core/src/main/java/com/scalar/db/common/DecoratedTwoPhaseCommitTransactionManager.java Delegated getScanner
core/src/main/java/com/scalar/db/common/DecoratedTwoPhaseCommitTransaction.java Delegated getScanner
core/src/main/java/com/scalar/db/common/DecoratedDistributedTransactionManager.java Delegated getScanner
core/src/main/java/com/scalar/db/common/DecoratedDistributedTransaction.java Delegated getScanner
core/src/main/java/com/scalar/db/common/ActiveTransactionManagedTwoPhaseCommitTransactionManager.java Synchronized override getScanner
core/src/main/java/com/scalar/db/common/ActiveTransactionManagedDistributedTransactionManager.java Synchronized override getScanner
core/src/main/java/com/scalar/db/common/AbstractTransactionManagerCrudOperableScanner.java Added abstract manager-scanner adapter
core/src/main/java/com/scalar/db/common/AbstractTransactionCrudOperableScanner.java Added abstract transaction-scanner adapter
core/src/main/java/com/scalar/db/common/AbstractCrudOperableScanner.java Implemented shared scanner iterator logic
core/src/main/java/com/scalar/db/api/TransactionManagerCrudOperable.java Extended API with getScanner and nested Scanner
core/src/main/java/com/scalar/db/api/TransactionCrudOperable.java Extended API with getScanner and nested Scanner
core/src/main/java/com/scalar/db/api/CrudOperable.java Added getScanner to base CRUD API and nested Scanner
core/src/integration-test/java/com/scalar/db/transaction/jdbc/JdbcTransactionIntegrationTest.java Added placeholder tests for getScanner
Comments suppressed due to low confidence (3)

core/src/integration-test/java/com/scalar/db/transaction/jdbc/JdbcTransactionIntegrationTest.java:46

  • These placeholder tests for getScanner have no assertions; consider implementing actual coverage or removing them until behavior is defined.
@Disabled("Implement later")

core/src/main/java/com/scalar/db/common/DecoratedTwoPhaseCommitTransactionManager.java:115

  • [nitpick] This override is boilerplate repeated across many classes; consider providing a default method in the interface to reduce duplication.
public Scanner getScanner(Scan scan) throws CrudException {

core/src/main/java/com/scalar/db/api/CrudOperable.java:61

  • [nitpick] Since most implementations throw UnsupportedOperationException, you could provide a default interface implementation that throws a consistent exception, avoiding the need to add stubs everywhere.
Scanner<E> getScanner(Scan scan) throws E;

* (e.g., a conflict error). You can retry the transaction from the beginning
* @throws CrudException if the transaction CRUD operation fails due to transient or nontransient
* faults. You can try retrying the transaction from the beginning, but the transaction may
* still fail if the cause is nontranient
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word "nontranient" is a typo; it should be spelled "nontransient".

Suggested change
* still fail if the cause is nontranient
* still fail if the cause is nontransient

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it in a separate PR.

* (e.g., a conflict error). You can retry the transaction from the beginning
* @throws CrudException if the transaction CRUD operation fails due to transient or nontransient
* faults. You can try retrying the transaction from the beginning, but the transaction may
* still fail if the cause is nontranient
Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word "nontranient" is a typo; it should be spelled "nontransient".

Suggested change
* still fail if the cause is nontranient
* still fail if the cause is nontransient

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

@brfrn169 brfrn169 May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix it in a separate PR.

throw e;
}
}

Copy link

Copilot AI May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The stub override lacks JavaDoc. Even a brief @throws UnsupportedOperationException note would clarify the intent.

Suggested change
/**
* This method is not yet implemented.
*
* @param scan the scan operation to perform
* @return nothing, as this method always throws an exception
* @throws UnsupportedOperationException always, as this method is a stub
*/

Copilot uses AI. Check for mistakes.
* @return a {@code Scanner} to iterate over the results
* @throws E if the transaction CRUD operation fails
*/
Scanner<E> getScanner(Scan scan) throws E;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the getScanner() method to CrudOperable.

void mutate(List<? extends Mutation> mutations) throws E;

/** A scanner abstraction for iterating results. */
interface Scanner<E extends TransactionException> extends AutoCloseable, Iterable<Result> {
Copy link
Collaborator Author

@brfrn169 brfrn169 May 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, added the Scanner interface to CrudOperable.

* still fail if the cause is nontranient
*/
@Override
Scanner getScanner(Scan scan) throws CrudConflictException, CrudException;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, added the getScanner() method and the Scanner interface to TransactionManagerCrudOperable.

* still fail if the cause is nontranient
*/
@Override
Scanner getScanner(Scan scan) throws CrudConflictException, CrudException;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, added the getScanner() method and the Scanner interface to TransactionCrudOperable.

@Override
@Nonnull
public Iterator<Result> iterator() {
if (scannerIterator == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on this implementation, this class should be also @NotThreadSafe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should add @NotThreadSafe to abstract classes? Actually, we basically don’t do that at the moment.

@brfrn169 brfrn169 requested a review from komamitsu May 27, 2025 04:54
Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

Comment on lines 161 to 166
/**
* Returns the first result in the results.
*
* @return the first result in the results
* @throws E if the operation fails
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Javadoc was copied from com.scalar.db.api.Scanner, but I think it could be improved to be clear one() iterates over the results.

Suggested change
/**
* Returns the first result in the results.
*
* @return the first result in the results
* @throws E if the operation fails
*/
/**
* Returns the next result.
*
* @return an Optional containing the next result if available, or empty if no more results
* @throws E if the operation fails
*/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8ae4db1. Thanks!

Comment on lines 169 to 174
/**
* Returns all the results.
*
* @return the list of {@code Result}s
* @throws E if the operation fails
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise to the comment above. I think the Javadoc should be more clear that it iterates over the results.

Suggested change
/**
* Returns all the results.
*
* @return the list of {@code Result}s
* @throws E if the operation fails
*/
/**
* Returns all remaining results.
*
* @return a List containing all remaining results
* @throws E if the operation fails
*/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8ae4db1. Thanks!

@brfrn169 brfrn169 requested a review from Torch3333 May 28, 2025 05:55
Copy link
Contributor

@Torch3333 Torch3333 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@brfrn169 brfrn169 merged commit da1cb57 into add-scanner-api-to-transaction-abstraction May 28, 2025
55 checks passed
@brfrn169 brfrn169 deleted the add-getScanner-to-transaction-interfaces branch May 28, 2025 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants